package lixp.rabbitmqAdvance.producer.controller;

import lixp.rabbitmqAdvance.producer.service.ProCreateService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProController {

    @Autowired
    private RabbitTemplate rabbit;

    @Autowired
    ProCreateService proCreateService;

    @GetMapping("/queue_test")
    public String produce(String queueName ,String exchange ,String message){
        proCreateService.createMQIfNotExist(queueName,exchange);
        rabbit.convertAndSend(queueName,message);
        return "消息已经发送";
    }
}
